package name.zxw.vue.controller;

import name.zxw.vue.entity.Car;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ZhangXinWang
 * @date 2022/6/6 0:49
 */
@RestController
public class CarController {

    private static List<Car> cars;

    public CarController() {
        initData();
    }

    private void initData() {
        cars = new ArrayList<>();
        cars.add(new Car("001", "奔驰", 199));
        cars.add(new Car("002", "马自达", 109));
        cars.add(new Car("003", "捷达", 120));
    }

    @GetMapping("/cars")
    public List<Car> showCars() {
        System.out.println("有人请求服务器2了");
        return cars;
    }


}
